package listbyorder.access101_200.test187;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/15 10:31
 */
public class Solution1 {

    // 重复的DNA序列
    public List<String> findRepeatedDnaSequences(String s) {
        HashSet<String> set = new HashSet<>();
        Set<String> ans = new HashSet<>();
        for (int i = 0; i + 10 <= s.length(); i++) {
            String cur = s.substring(i, i + 10);
            if (set.contains(cur)) {
                ans.add(cur);
            } else {
                set.add(cur);
            }
        }
        return new ArrayList<>(ans);
    }

}
